package org.jet.emall.prod.transfer;

import org.jet.emall.prod.custom.po.AttrPO;
import org.jet.emall.prod.custom.po.SpecPO;
import org.jet.emall.prod.dto.AttrDTO;
import org.jet.emall.prod.dto.SkuDTO;
import org.jet.emall.prod.dto.SkuImageDTO;
import org.jet.emall.prod.dto.SpecDTO;
import org.jet.emall.prod.po.ProdSkuImage;
import org.jet.emall.prod.po.SkuView;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author xiaozai
 * @version 1.0
 * @date 2020-04-25 12:29
 */
@Mapper
public interface SkuDtoTransfer {

    SkuDtoTransfer INSTANCE = Mappers.getMapper(SkuDtoTransfer.class);


    /**
     *  将SKUVIEW PO列表转VO列表
     * @param records
     * @return
     */
    List<SkuDTO> toDtoList(List<SkuView> records);

    /**
     *  将 属性PO转DTO
     * @param attrPO
     * @return
     */
    @Mappings({
            @Mapping(target = "name",source = "attrName"),
            @Mapping(target = "value",source = "attrOptionValue")
    })
    AttrDTO toAttrDto(AttrPO attrPO);

    /**
     *  将属性PO列表转DTO列表
     * @param attrPOList
     * @return
     */
    List<AttrDTO> toAttrDtoList(List<AttrPO> attrPOList);

    /**
     *  将规格PO转DTO
     * @param specPO
     * @return
     */
    @Mappings({
            @Mapping(target = "name",source = "specName"),
            @Mapping(target = "value",source = "specOptionValue")
    })
    SpecDTO toSpecDto(SpecPO specPO);


    /**
     *   将规格PO列表转DTO列表
     * @param specPOList
     * @return
     */
    List<SpecDTO> toSpecDtoList(List<SpecPO> specPOList);

    /**
     *  将SKU的图片PO列表转DTO
     * @param skuImages
     * @return
     */
    List<SkuImageDTO> toImageDtoList(List<ProdSkuImage> skuImages);
}
